<html xmlns:th="http://www.thymeleaf.org">
<input type="hidden" id="id" name="id" th:value="${sysPermission.id}">
<input type="hidden" id="clientId" name="clientId" th:value="${sysPermission.clientId}">
<table class="editTable">
    <thead>
    <tr>
        <td colspan="8">
            <div class="divider">
                <span> 基本信息</span>
            </div>
        </td>
    </tr>
    <tr>
        <th class="label" width="8%"><span class="span_red">*</span>权限名称</th>
        <td width="42%">
            <input type="text" name="name" data-toggle="topjui-textbox"
                   data-options="required:true,validateOnCreate:false,width:250" th:value="${sysPermission.name}">
        </td>
        <th class="label" width="8%"><span class="span_red">*</span>权限code</th>
        <td width="42%">
            <input type="text" name="code" data-toggle="topjui-textbox"
                   data-options="required:true,validateOnCreate:false,width:250" th:value="${sysPermission.code}">
        </td>
    </tr>
    <tr>
        <th class="label" width="8%"><span class="span_red">*</span>菜单图标</th>
        <td width="42%">
            <input type="text" name="icon" data-toggle="topjui-textbox"
                   data-options="required:true,width:250" th:value="${sysPermission.icon}">
        </td>
        <th class="label" >状态</th>
        <td>
            <div data-toggle="topjui-radio">
                <input type="hidden" id="sysPermissionStatus" th:value="${sysPermission.status}" >
                <input type="radio" name="status" value="ENABLE" label="启用">
                <input type="radio" name="status" value="DISABLE" label="禁用">
            </div>
        </td>
    </tr>
    <tr>
        <th class="label" width="8%">父权限</th>
        <td width="42%">
            <input type="text" name="pid" th:value="${sysPermission.pid}"
                   data-toggle="topjui-combotree">
        </td>
    </tr>
    <tr>
        <th>&nbsp;</th>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <th class="label" >说明</th>
        <td colspan="3">
            <input type="text" name="description" data-toggle="topjui-textbox" style="width: 94%;" th:value="${sysPermission.description}">
        </td>
    </tr>
    </thead>
</table>

<script th:inline="javascript">
    /**
     * 权限状态设置
     */
    var status = $("#sysPermissionStatus").val();
    var radios = $(".editTable").find("input[name='status']");
    if (status == "DISABLE") {
        $(radios[1]).attr("checked","checked");
    } else {
        $(radios[0]).attr("checked","checked");
    }

    //TODO: 获取项目上下文路径，记得需要在<script>标签中加入  th:inline="javascript" 属性配置，才可正常解析
    /*<![CDATA[*/
    var contextPath = /*[[@{/}]]*/;
    /*]]>*/

    /**
     * 动态设置父权限的url
     */
    $(document).ready(function () {
        //var id = [[${sysPermission.id}]];
        $("input[name='pid']").attr("data-options","required:true,prompt:'必填',width:250,textField:'name'," +
            "url:'" + contextPath + "permission/list/not/itself/" + $("#id").val() + "/" + $("#clientId").val() + "'");
    });
</script>

</html>